<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增大区会长产品合作')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-agentCooperate-add">
            <h4 class="form-header h4">大区会长产品合作信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label">会长id：</label>
                <div class="col-sm-8">
                    <input name="agentId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">产品id：</label>
                <div class="col-sm-8">
                    <input name="partsId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">区域内人口总数：</label>
                <div class="col-sm-8">
                    <input name="peopleNum" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">销售额：</label>
                <div class="col-sm-8">
                    <input name="salesVolume" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">保证金：</label>
                <div class="col-sm-8">
                    <input name="earnestMoney" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">政策简介：</label>
                <div class="col-sm-8">
                    <textarea name="cooperationPolicy" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否已缴纳保证金 1是 0否：</label>
                <div class="col-sm-8">
                    <select name="isPay" class="form-control m-b" th:with="type=${@dict.getType('zsyh_yesno')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">人口销售额比例：</label>
                <div class="col-sm-8">
                    <input name="populationSalesRatio" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">销售额定金比例：</label>
                <div class="col-sm-8">
                    <input name="salesPaymentRatio" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合作产品的年份：</label>
                <div class="col-sm-8">
                    <input name="year" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remarks" class="form-control"></textarea>
                </div>
            </div>
            <h4 class="form-header h4">大区会长产品合作区域信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/agentCooperate"
        $("#form-agentCooperate-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-agentCooperate-add').serialize());
            }
        }

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '修改时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'agentId',
                    align: 'center',
                    title: '会长id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].agentId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'partsId',
                    align: 'center',
                    title: '产品id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].partsId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'year',
                    align: 'center',
                    title: '合作产品的年份',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].year' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'province',
                    align: 'center',
                    title: '省份code',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].province' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'provinceName',
                    align: 'center',
                    title: '省份名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].provinceName' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'city',
                    align: 'center',
                    title: '市区code',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].city' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'cityName',
                    align: 'center',
                    title: '市区名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].cityName' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'district',
                    align: 'center',
                    title: '区县code',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].district' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'districtName',
                    align: 'center',
                    title: '区县名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentCooperateRelList[%s].districtName' value='%s'>", index, value);
                        return html;
                    }
                
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    createTime: "",
                    updateTime: "",
                    agentId: "",
                    partsId: "",
                    year: "",
                    province: "",
                    provinceName: "",
                    city: "",
                    cityName: "",
                    district: "",
                    districtName: ""
                }
            });
        }
    </script>
</body>
</html>